package org.example;

import dao.BookDao;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import service.BookService;

/**
 * 用bean的方法来运行
 * 要想拿bean,先拿IOC容器
 */
public class App2 {
    public static void main(String[] args) {
        //1, 获取Ioc容器
        ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
        // 2 . 拿bean
        BookDao bookDao =(BookDao) ctx.getBean("bookDao");
        bookDao.save();
       /* // service拿对象我们放在APP3里讲
        BookService bookService =(BookService) ctx.getBean("bookService");
        bookService.save();*/

    }
}
